<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const categories = [
  { 
    id: 'frontend', 
    name: '前端开发', 
    icon: 'fa-code',
    color: '#3498db',
    description: '学习HTML、CSS、JavaScript以及现代前端框架',
    courses: 42
  },
  { 
    id: 'mobile', 
    name: '移动开发', 
    icon: 'fa-mobile-alt',
    color: '#e74c3c',
    description: '掌握iOS、Android和跨平台移动应用开发',
    courses: 38
  },
  { 
    id: 'games', 
    name: '游戏开发', 
    icon: 'fa-gamepad',
    color: '#9b59b6',
    description: '学习游戏设计、开发和发布的全套技能',
    courses: 27
  },
  { 
    id: 'backend', 
    name: '后端开发', 
    icon: 'fa-server',
    color: '#2ecc71',
    description: '掌握服务器端编程、API设计和数据库管理',
    courses: 45
  },
  { 
    id: 'security', 
    name: '信息安全', 
    icon: 'fa-shield-alt',
    color: '#f39c12',
    description: '学习网络安全、加密和渗透测试技术',
    courses: 31
  },
  { 
    id: 'ai', 
    name: '人工智能', 
    icon: 'fa-brain',
    color: '#1abc9c',
    description: '探索机器学习、深度学习和AI应用开发',
    courses: 29
  },
  { 
    id: 'iot', 
    name: '智能硬件/物联网', 
    icon: 'fa-microchip',
    color: '#e67e22',
    description: '学习硬件编程、传感器集成和IoT解决方案',
    courses: 24
  },
  { 
    id: 'bigdata', 
    name: '大数据', 
    icon: 'fa-database',
    color: '#34495e',
    description: '掌握数据处理、分析和可视化技术',
    courses: 33
  },
  { 
    id: 'cloud', 
    name: '云原生', 
    icon: 'fa-cloud',
    color: '#16a085',
    description: '学习云计算、容器化和微服务架构',
    courses: 26
  },
  { 
    id: 'database', 
    name: '数据库', 
    icon: 'fa-table',
    color: '#27ae60',
    description: '深入了解SQL、NoSQL和数据库优化技术',
    courses: 36
  }
];

const navigateToCategory = (categoryId) => {
  // 这里可以导航到特定类别的页面
  router.push(`/learning/${categoryId}`);
};
</script>

<template>
  <div class="categories-container">
    <div class="categories-header">
      <h1>学习路径分类</h1>
      <p class="subtitle">选择您感兴趣的技术领域，开始学习之旅</p>
    </div>
    
    <div class="search-container">
      <div class="search-box">
        <i class="fas fa-search search-icon"></i>
        <input type="text" placeholder="搜索技术、课程或主题..." />
      </div>
    </div>
    
    <div class="categories-grid">
      <div 
        v-for="category in categories" 
        :key="category.id"
        class="category-card"
        @click="navigateToCategory(category.id)"
      >
        <div class="card-header" :style="{ backgroundColor: category.color }">
          <i :class="['fas', category.icon, 'category-icon']"></i>
        </div>
        <div class="card-body">
          <h3>{{ category.name }}</h3>
          <p>{{ category.description }}</p>
          <div class="card-footer">
            <span class="course-count">{{ category.courses }} 门课程</span>
            <span class="explore-link">探索 <i class="fas fa-arrow-right"></i></span>
          </div>
        </div>
      </div>
    </div>
    
    <div class="recommended-section">
      <h2>推荐学习路径</h2>
      <div class="path-cards">
        <div class="path-card">
          <div class="path-header">
            <span class="path-badge">热门</span>
            <h3>Web全栈工程师</h3>
          </div>
          <p>从前端到后端，掌握全栈开发技能，成为全能型开发者</p>
          <div class="path-stats">
            <span><i class="fas fa-book"></i> 24 门课程</span>
            <span><i class="fas fa-clock"></i> 120 小时</span>
          </div>
          <button class="path-btn">开始学习</button>
        </div>
        
        <div class="path-card">
          <div class="path-header">
            <span class="path-badge new">新课</span>
            <h3>AI应用开发专家</h3>
          </div>
          <p>学习将AI技术集成到应用程序中，打造智能化产品和服务</p>
          <div class="path-stats">
            <span><i class="fas fa-book"></i> 18 门课程</span>
            <span><i class="fas fa-clock"></i> 90 小时</span>
          </div>
          <button class="path-btn">开始学习</button>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.categories-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.categories-header {
  text-align: center;
  margin-bottom: 40px;
}

.categories-header h1 {
  font-size: 36px;
  color: #2c3e50;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 18px;
  color: #7f8c8d;
}

.search-container {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}

.search-box {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 600px;
  background-color: #f8f9fa;
  border-radius: 50px;
  padding: 0 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.search-box:focus-within {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.search-icon {
  color: #95a5a6;
  margin-right: 10px;
}

.search-box input {
  width: 100%;
  padding: 15px 0;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #34495e;
}

.search-box input:focus {
  outline: none;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  margin-bottom: 60px;
}

.category-card {
  background-color: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
}

.category-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.card-header {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-icon {
  font-size: 40px;
  color: white;
}

.card-body {
  padding: 20px;
}

.card-body h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #2c3e50;
  font-size: 20px;
}

.card-body p {
  color: #7f8c8d;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ecf0f1;
  padding-top: 15px;
}

.course-count {
  font-size: 14px;
  color: #7f8c8d;
}

.explore-link {
  color: #3498db;
  font-weight: 600;
  font-size: 14px;
}

.explore-link i {
  margin-left: 5px;
  transition: transform 0.2s ease;
}

.category-card:hover .explore-link i {
  transform: translateX(3px);
}

.recommended-section {
  margin-top: 80px;
}

.recommended-section h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #2c3e50;
  font-size: 28px;
}

.path-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
}

.path-card {
  background-color: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.path-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.path-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.path-badge {
  background-color: #e74c3c;
  color: white;
  font-size: 12px;
  font-weight: bold;
  padding: 5px 10px;
  border-radius: 20px;
  margin-right: 10px;
}

.path-badge.new {
  background-color: #2ecc71;
}

.path-header h3 {
  margin: 0;
  color: #2c3e50;
  font-size: 20px;
}

.path-card p {
  color: #7f8c8d;
  margin-bottom: 20px;
  line-height: 1.5;
}

.path-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  color: #7f8c8d;
  font-size: 14px;
}

.path-stats i {
  margin-right: 5px;
}

.path-btn {
  width: 100%;
  background-color: #3498db;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.path-btn:hover {
  background-color: #2980b9;
}

@media (max-width: 768px) {
  .categories-header h1 {
    font-size: 28px;
  }

  .subtitle {
    font-size: 16px;
  }
  
  .path-cards {
    grid-template-columns: 1fr;
  }
}
</style> 